<html xmlns:MSHelp="http://msdn.microsoft.com/mshelp"><head>
   <title>Sample Scenarios</title>
   <meta name="generator"  content="HelpMaker.net" >
   <meta name="keywords"  content="Topic 2," ><LINK REL="stylesheet" TYPE="text/css" HREF="ms-help://Hx/HxRuntime/HxLink.css"><LINK REL="stylesheet" TYPE="text/css" HREF="ms-help://Hx/HxRuntime/HxLinkDefault.css"></head>
<body bgcolor="FFFFFF" >
    <table cellpadding="0" cellspacing="0" width="100%">
      <tr>
        <td style="background-image:url(../images/bk_tl.jpg); background-repeat: repeat-x"><img src="../images/space.gif" width=4 height=4></td>
        <td style="background-image:url(../images/bk_t.jpg); background-repeat: repeat-x"><img src="../images/space.gif" width=4 height=4></td>
        <td style="background-image:url(../images/bk_tr.jpg); background-repeat: repeat-x"><img src="../images/space.gif" width=4 height=4></td>
      </tr>
      <tr>
        <td width="4" style="background-image:url(../images/bk_l.jpg); background-repeat: repeat-y"><img src="../images/space.gif" width=4 height=4></td>
        <td width="100%" style="font-family: sans-serif; font-weight: bold; font-size: 14pt; background-image:url(../images/bk_c.jpg); background-repeat: repeat">
          &nbsp;Sample Scenarios
        </td>
        <td width="4" style="background-image:url(../images/bk_r.jpg); background-repeat: repeat-y"><img src="../images/space.gif" width=4 height=4></td>
      </tr>
      <tr>
        <td height="4" style="background-image:url(../images/bk_bl.jpg); background-repeat: repeat-x"><img src="../images/space.gif" width=4 height=4></td>
        <td style="background-image:url(../images/bk_b.jpg); background-repeat: repeat-x"><img src="../images/space.gif" width=4 height=4></td>
        <td style="background-image:url(../images/bk_br.jpg); background-repeat: repeat-x"><img src="../images/space.gif" width=4 height=4></td>
      </tr>
    </table>
<br>

<font face="Arial"  color="#010101"  size="4" ><span style="font-size:14pt" ><b>Example 1</b></span></font><font color="#010101" ></font><br><p align="justify" ><font face="Arial"  color="#010101" ><span style="font-size:10pt" >For example, to change directory the client sends:</span></font><font color="#010101" ></font><br><p style="margin-left:13mm; margin-right:0mm; text-indent:0mm; " ><font face="Courier New"  color="#010101" ><span style="font-size:10pt" >&gt; CWD dirname</span></font><font color="#010101" ></font><br><p align="justify" ><font face="Arial"  color="#010101" ><span style="font-size:10pt" >The server responds with:</span></font><font color="#010101" ></font><br><p style="margin-left:13mm; margin-right:0mm; text-indent:0mm; " ><font face="Courier New"  color="#010101" ><span style="font-size:10pt" >250 CWD command successful</span></font><font color="#010101" ></font><br><p align="justify" ><font face="Arial"  color="#010101" ><span style="font-size:10pt" >As the reply begins with a &lsquo;2&rsquo;, we know the command sequence is completed. </span></font><font color="#010101" ></font><br><p align="justify" ><font face="Arial"  color="#010101" ><span style="font-size:10pt" >However if we attempt to change directory to one that does not exist:</span></font><font color="#010101" ></font><br><p style="margin-left:13mm; margin-right:0mm; text-indent:0mm; " ><font face="Courier New"  color="#010101" ><span style="font-size:10pt" >&gt; CWD nonexistentdir</span></font><font color="#010101" ></font><br><p align="justify" ><font face="Arial"  color="#010101" ><span style="font-size:10pt" >The server responds with:</span></font><font color="#010101" ></font><br><p style="margin-left:13mm; margin-right:0mm; text-indent:0mm; " ><font face="Courier New"  color="#010101" ><span style="font-size:10pt" >550 nonexistentdir: The system cannot find the file specified.</span></font><font color="#010101" ></font><br><p align="justify" ><font face="Arial"  color="#010101" ><span style="font-size:10pt" >As the reply begins with a &lsquo;5&rsquo; we know that the command failed.</span></font><font color="#010101" ></font><br><p align="justify" ><br><br><font color="#010101" ><p align="justify" ></font><font color="#010101" ></font><br><font face="Arial"  color="#010101"  size="4" ><span style="font-size:14pt" ><b>Example 2</b></span></font><font color="#010101" ></font><br><p align="justify" ><font face="Arial"  color="#010101" ><span style="font-size:10pt" >To transfer a text file, we issue a &lsquo;RETR&rsquo; command to the server.&nbsp; However to transfer the file
we require a data connection to be set up. This can be done using active or passive mode.</span></font><font color="#010101" ></font><br><p align="justify" ><font face="Arial"  color="#010101" ><span style="font-size:10pt" >As discussed previously, in active mode, the client sends a &lsquo;PORT&rsquo; command, indicating what
address and port number the server should connect to:</span></font><font color="#010101" ></font><br><p style="margin-left:13mm; margin-right:0mm; text-indent:0mm; " ><font face="Courier New"  color="#010101" ><span style="font-size:10pt" >&gt; PORT 192,168,10,1,4,93</span></font><font color="#010101" ></font><br><p align="justify" ><font face="Arial"  color="#010101" ><span style="font-size:10pt" >The first four digits are the IP address, and the last two encode the port number (in two 8-bit
fields, the first being the high order bits of the 16-bit port number).</span></font><font color="#010101" ></font><br><p align="justify" ><font face="Arial"  color="#010101" ><span style="font-size:10pt" >The server responds with:</span></font><font color="#010101" ></font><br><p style="margin-left:13mm; margin-right:0mm; text-indent:0mm; " ><font face="Courier New"  color="#010101" ><span style="font-size:10pt" >200 PORT command successful.</span></font><font color="#010101" ></font><br><p align="justify" ><font face="Arial"  color="#010101" ><span style="font-size:10pt" >This indicates that the data connection has been established.</span></font><font color="#010101" ></font><br><p align="justify" ><br><br><font color="#010101" ><p align="justify" ></font><font face="Arial"  color="#010101" ><span style="font-size:10pt" >Next, the &lsquo;RETR&rsquo; command is issued:</span></font><font color="#010101" ></font><br><p style="margin-left:13mm; margin-right:0mm; text-indent:0mm; " ><font face="Courier New"  color="#010101" ><span style="font-size:10pt" >&gt; RETR abc.txt</span></font><font color="#010101" ></font><br><p align="justify" ><font face="Arial"  color="#010101" ><span style="font-size:10pt" >The server responds with:</span></font><font color="#010101" ></font><br><p style="margin-left:13mm; margin-right:0mm; text-indent:0mm; " ><font face="Courier New"  color="#010101" ><span style="font-size:10pt" >150 Opening ASCII mode data connection for abc.txt(70776
bytes). </span></font><font color="#010101" ></font><br><p align="justify" ><font face="Arial"  color="#010101" ><span style="font-size:10pt" >The reply begins with a &lsquo;1&rsquo;, so we know that the command was successful, but the server will
be sending another reply &ndash; the client cannot issue another command until this is received.</span></font><font color="#010101" ></font><br><p align="justify" ><font face="Arial"  color="#010101" ><span style="font-size:10pt" >Eventually, the server sends:</span></font><font color="#010101" ></font><br><p style="margin-left:13mm; margin-right:0mm; text-indent:0mm; " ><font face="Courier New"  color="#010101" ><span style="font-size:10pt" >226 Transfer complete.</span></font><font color="#010101" ></font><br><p align="justify" ><font face="Arial"  color="#010101" ><span style="font-size:10pt" >The command sequence is complete, the file has been transferred, and the client can issue
another command.</span></font><font color="#010101" ></font><br><p align="justify" ><font face="Arial"  color="#010101" ><span style="font-size:10pt" >See RFC 959 for details about the second digit, and more extensive examples.</span></font><font color="#010101" ></font><br><p align="justify" ><font face="Arial"  color="#010101" ><span style="font-size:10pt" >Note that most standard command-line FTP clients support debug mode, which displays the
FTP commands that are being sent to the server, and the reply strings that are received back.
Typing &ldquo;debug&rdquo; at the prompt will usually put the client into debug mode.</span></font><font color="#010101" ></font><br><div align="left" ><br></div><font color="#010101" ><div align="left" ></font><font face="Arial" ><span style="font-size:10pt" >Next: </span></font><a href="datatypes.html"><font face="Arial"  color="#0000ff" ><span style="font-size:10pt" ><u>Data Types</u></span></font></a><font color="#010101" ></font></div>

</body></html>
